Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: reusing PagingData crash [WPB-15055][WPB-15079][WPB-15064] #3758

Merged
merged 7 commits into from
Dec 30, 2024

Conversation

saleniuk
Copy link
Contributor

@saleniuk saleniuk commented Dec 18, 2024

BugWPB-15055 [Android] Crash when opening connection request from paginated list


PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

Issues

There are crashes related to reusing PagingData flow when doing some actions on paginated conversation list screen, like accepting legal hold request, answering 1:1 call or opening pending connection request which can fetch user data.

Causes (Optional)

Each action that modifies (or even puts the same exact data but just requires executing insert, update or delete query) a table that then affects paginated conversation list query, makes this query dirty and executes it again, which reloads the list.
When using combine, it creates a new instance of flow, so if the combine is used after PagingData is created then if the data is changed and emitted by the flow that's combined, it will re-use the same PagingData and put it into a new flow, so cachedIn won't cache the flow properly and it will crash because PagingData cannot be used twice.

Solutions

Move combine "above" the PagingData flow so that each time a new value is emitted, it will always create a new PagingData for the new flow and also cachedIn will be used correctly.
Simplify showLoading parameter to be a simple logical equation rather than a state. Make use of mocked previewConversationFoldersFlow with proper LoadStates to represent loaded data instead of using specific initiallyLoaded parameter.
Fix rememberSearchbarState so that it actually saves the searchQueryTextState.

Testing

Test Coverage (Optional)

  • I have added automated test to this contribution

How to Test

The crash was happening when opening pending connection request (most frequently), answering 1:1 call or accepting legal hold request, so these actions shouldn't crash the app. Also, after opening connection request or 1:1 conversation, if your or that user's data hasn't changed since the last fetch, then it shouldn't refresh the conversation list when navigating back.

Attachments (Optional)

Before After
refreshing_when_going_back.mp4
no_refreshing_when_going_back.mp4
pagination_crash.mp4

PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

@echoes-hq echoes-hq bot added the echoes: unplanned Any work item that isn’t part of the product or technical roadmap. label Dec 18, 2024
Copy link
Contributor

Built wire-android-staging-compat-pr-3758.apk is available for download

@saleniuk saleniuk requested review from a team, typfel, alexandreferris, MohamadJaara, Garzas and ohassine and removed request for a team December 19, 2024 08:22
Copy link
Contributor

@borichellow borichellow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good and very nice catch! Just a small suggestion

@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 44.23077% with 29 lines in your changes missing coverage. Please review.

Project coverage is 45.69%. Comparing base (10efa7e) to head (63dfb82).

Files with missing lines Patch % Lines
...ome/conversationslist/ConversationListViewModel.kt 44.23% 23 Missing and 6 partials ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##           release/candidate    #3758   +/-   ##
==================================================
  Coverage              45.69%   45.69%           
==================================================
  Files                    473      473           
  Lines                  16115    16123    +8     
  Branches                2724     2725    +1     
==================================================
+ Hits                    7363     7367    +4     
- Misses                  7986     7989    +3     
- Partials                 766      767    +1     
Files with missing lines Coverage Δ
...ome/conversationslist/ConversationListViewModel.kt 34.14% <44.23%> (+1.79%) ⬆️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 10efa7e...63dfb82. Read the comment docs.

Copy link
Contributor

Built wire-android-staging-compat-pr-3758.apk is available for download

@saleniuk saleniuk added this pull request to the merge queue Dec 30, 2024
Merged via the queue into release/candidate with commit 58d3802 Dec 30, 2024
14 of 15 checks passed
@saleniuk saleniuk deleted the fix/reusing_pagingdata_crash branch December 30, 2024 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
echoes: unplanned Any work item that isn’t part of the product or technical roadmap. size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants